home *** CD-ROM | disk | FTP | other *** search
/ Nautilus 1992 July / Nautilus-3-8 / Nautilus-3-8.bin / Tools & Utilities / Techy Stuff / Doco ƒ / CSMP ƒ / CSMP-V1-093.TXT < prev    next >
Encoding:
Text File  |  1992-06-30  |  34.5 KB  |  933 lines

  1. C.S.M.P. Digest             Mon, 25 May 92       Volume 1 : Issue 93
  2.  
  3. Today's Topics:
  4.  
  5.     Want to trap writeln/readln in MPW pascal
  6.     "Faceless" applications
  7.     MF scrap && DialogSelect crash
  8.     FileFilter Procedure.  Think C 5.0 StandardGetDialog.
  9.     smooth scrolling
  10.     Are you a developer? Ive got a question.
  11.  
  12.  
  13. The Comp.Sys.Mac.Programmer Digest is moderated by Michael A. Kelly.
  14.  
  15. These digests are available (by using FTP, account anonymous, your email
  16. address as password) in the pub/mac/csmp-digest directory on ftp.cs.uoregon.
  17. edu.  This is also the home of the comp.sys.mac.programmer Frequently Asked
  18. Questions list.  The last several issues of the digest are available from
  19. sumex-aim.stanford.edu as well.
  20.  
  21. These digests are also available via email.  Just send a note saying that you
  22. want to be on the digest mailing list to mkelly@cs.uoregon.edu, and you will
  23. automatically receive each new digest as it is created.
  24.  
  25. The digest is a collection of articles from the internet newsgroup comp.sys.
  26. mac.programmer.  It is designed for people who read c.s.m.p. semi-regularly
  27. and want an archive of the discussions.  If you don't know what a newsgroup
  28. is, you probably don't have access to it.  Ask your systems administrator(s)
  29. for details.  (This means you can't post questions to the digest.)
  30.  
  31. The articles in these digests are taken directly from comp.sys.mac.programmer.
  32. They are not edited; all articles included in this digest are in their original
  33. posted form.  The only articles that are -not- included in these digests are
  34. those which didn't receive any replies (except those that give information
  35. rather than ask a question).  All replies to each article are concatenated
  36. onto the original article in the order in which they were received.  Article
  37. threads are not added to the digests until the last article added to the
  38. thread is at least one month old (this is to ensure that the thread is dead
  39. before adding it to the digests).
  40.  
  41. Send administrative mail to mkelly@cs.uoregon.edu.
  42.  
  43. -------------------------------------------------------
  44.  
  45. From: jt8@cunixf.cc.columbia.edu (James Terman)
  46. Subject: Want to trap writeln/readln in MPW pascal
  47. Organization: Columbia University
  48. Date: Sun, 19 Apr 1992 07:58:04 GMT
  49.  
  50. I would like to use writeln/readln commands to write to a window/read from
  51. the keyboard.  Is there a procedure name that the compilier use that I could
  52. override from Paslib to put in my own routine?
  53.  
  54. | James L. Terman "Future Dead White Male" | Science may set limits to know-  |
  55. | jt8@cunixf.cc.columbia.edu               | ledge, but should not set limits |
  56. | JLT%CUTHRY.BITNET@cuvmb.cc.columbia.edu  | to imagination.              |
  57. |                       |            - Bertrand Russell |
  58.  
  59. +++++++++++++++++++++++++++
  60.  
  61. From: ags@mentor.cc.purdue.edu (Dave Seaman)
  62. Date: 19 Apr 92 16:43:59 GMT
  63. Organization: Purdue University Computing Center
  64.  
  65. In article <1992Apr19.075804.9435@cunixf.cc.columbia.edu> jt8@cunixf.cc.columbia.edu (James Terman) writes:
  66. >I would like to use writeln/readln commands to write to a window/read from
  67. >the keyboard.  Is there a procedure name that the compilier use that I could
  68. >override from Paslib to put in my own routine?
  69.  
  70. If you write an MPW tool program (not an application), then writeln and readln
  71. do what you want by default (i.e. unless you have specified redirection on the
  72. command line by using the Unix-style < and > operators).
  73.  
  74. Why do you want to override the existing routines?
  75.  
  76. - -- 
  77. Dave Seaman
  78. ags@seaman.cc.purdue.edu
  79.  
  80. +++++++++++++++++++++++++++
  81.  
  82. From: Keith_Rollin@taligent.com (Keith Rollin)
  83. Date: 23 Apr 92 21:58:04 GMT
  84. Organization: Taligent
  85.  
  86. In article <23837@goofy.Apple.COM>, jpugh@apple.com (Jon Pugh) writes:
  87. > In article <1992Apr19.075804.9435@cunixf.cc.columbia.edu>,
  88. jt8@cunixf.cc.columbia.edu (James Terman) writes:
  89. > > 
  90. > > I would like to use writeln/readln commands to write to a window/read from
  91. > > the keyboard.  Is there a procedure name that the compilier use that I could
  92. > > override from Paslib to put in my own routine?
  93. > There is a new library that I have heard of called SWIO or somesuch that
  94. > does Standard Window IO.  Look for it in the recent MPW releases.  I don't
  95. > have the info here, but it should be on ETO and maybe the Dev CD.
  96.  
  97. It's called SIOW, and it's part of MPW 3.2
  98.  
  99. - --
  100. Keith Rollin
  101. Phantom Programmer
  102. Taligent, Inc.
  103.  
  104. ---------------------------
  105.  
  106. From: s_fuller@iastate.edu (Steve Fuller)
  107. Subject: "Faceless" applications
  108. Organization: Iowa State University, Ames IA
  109. Date: Fri, 17 Apr 1992 20:51:29 GMT
  110.  
  111. After using Trashman and not having it show up in the task list,
  112. I'm wondering if it is possible to hack at a program with ResEdit
  113. and get it to not show up in the task list as well, or is this
  114. a feature that must be built into an appliction at compile
  115. time???
  116.  
  117.  
  118. - -- 
  119. - ---------------------=---------------------------------------------------
  120. Steve Fuller         = Critics are like eunuchs in a harem. They know
  121. Net.nerd             = how it's done, they've seen it done every day,
  122. s_fuller@iastate.edu = but they're unable to do it themselves. B. Behan
  123.  
  124. +++++++++++++++++++++++++++
  125.  
  126. From: dawg6844@uxa.cso.uiuc.edu (Dan Walkowski)
  127. Organization: University of Illinois at Urbana
  128. Date: Sat, 18 Apr 1992 03:30:38 GMT
  129.  
  130. s_fuller@iastate.edu (Steve Fuller) writes:
  131.  
  132. >After using Trashman and not having it show up in the task list,
  133. >I'm wondering if it is possible to hack at a program with ResEdit
  134. >and get it to not show up in the task list as well, or is this
  135. >a feature that must be built into an appliction at compile
  136. >time???
  137.  
  138.  
  139. >-- 
  140. Why didn't you just _ask_ me? :-)
  141. The short answer to your question is 'no'.
  142. The longer answer is 'No, because the program isn't allowed to call InitWindows
  143. (or InitMenus, I think) and must be of type 'appe', instead of APPL.'
  144. This means, of course, that no program that has any windows can do this.
  145. If you want more details, send me email.
  146.  
  147.  
  148. - -- 
  149. Dan Walkowski  
  150. Univ. of Illinois
  151. walkowsk@cs.uiuc.edu
  152. - ---------------------------------------------------------------------------
  153.  
  154. +++++++++++++++++++++++++++
  155.  
  156. From: jackl@Apple.COM (Jack Littleton)
  157. Date: 20 Apr 92 17:02:18 GMT
  158. Organization: Apple Computer Inc., Cupertino, CA
  159.  
  160. In article <s_fuller.703543889@vincent1.iastate.edu> s_fuller@iastate.edu (Steve Fuller) writes:
  161. >I'm wondering if it is possible to hack at a program with ResEdit
  162. >and get it to not show up in the task list as well, or is this
  163. >a feature that must be built into an appliction at compile
  164. >time???
  165.  
  166. You can partially make a program faceless by setting the "canBackground" and
  167. "onlyBackground" attributes are set in the SIZE resource.  However, since the
  168. by-laws of Faceless Applications state that they can olny receive high level
  169. and null events, just setting those attributes won't cut it.  Not only that,
  170. but if the program you modify draws windows, menus, etc., it totally blows
  171. the concept of "Facelessness".
  172.  
  173. I'm gonna get 'faced.
  174.  
  175. Jack Littleton
  176. Development Tools Engineering
  177. Apple Computer, Inc.
  178.  
  179. * The opinion stated above are not necessarily those of Apple Computer, Inc. *
  180.  
  181. - -- 
  182. Jack Littleton                Internet: jackl@apple.com
  183. MPW Compiler/Linker group     AppleLink: JACINTOSH
  184. Apple Computer, Inc.
  185.  
  186. +++++++++++++++++++++++++++
  187.  
  188. From: ross@bnr.ca (Ross Brown)
  189. Date: 21 Apr 92 12:14:17 GMT
  190. Organization: Bell-Northern Research
  191.  
  192. In article <65703@apple.Apple.COM> jackl@Apple.COM (Jack Littleton) writes:
  193. >You can partially make a program faceless by setting the "canBackground" and
  194. >"onlyBackground" attributes are set in the SIZE resource.  However, since the
  195. >by-laws of Faceless Applications state that they can olny receive high level
  196. >and null events, just setting those attributes won't cut it.  Not only that,
  197. >but if the program you modify draws windows, menus, etc., it totally blows
  198. >the concept of "Facelessness".
  199.  
  200. Please, where are these "by-laws" recorded?  There's not much in IM VI about
  201. background-only applications.
  202.  
  203. Ross Brown
  204. Bell-Northern Research Ltd.
  205. Ottawa, Ontario, Canada
  206. ross@bnr.ca
  207. Opinions expressed do not necessarily represent those of BNR.
  208.  
  209. +++++++++++++++++++++++++++
  210.  
  211. From: mwalker@wc.novell.com (Mel Walker)
  212. Organization: Novell, Inc. - Walnut Creek
  213. Date: Tue, 21 Apr 1992 15:58:00 GMT
  214.  
  215. In article <1992Apr21.121417.23876@bmers95.bnr.ca> ross@bnr.ca (Ross Brown) writes:
  216. >In article <65703@apple.Apple.COM> jackl@Apple.COM (Jack Littleton) writes:
  217. >>You can partially make a program faceless by setting the "canBackground" and
  218. >>"onlyBackground" attributes are set in the SIZE resource.  However, since the
  219. >>by-laws of Faceless Applications state that they can olny receive high level
  220. >>and null events, just setting those attributes won't cut it.  Not only that,
  221. >>but if the program you modify draws windows, menus, etc., it totally blows
  222. >>the concept of "Facelessness".
  223. >
  224. >Please, where are these "by-laws" recorded?  There's not much in IM VI about
  225. >background-only applications.
  226.  
  227. They're not so much "laws" as "consequences". They recieve null events since
  228. they're in the background, and they can receive high-level events if the
  229. appropriate bit is set. They can't receive activate/update events (no windows),
  230. mousedown/up events (no windows, in the background), os events (since they are
  231. _always_ in the background), keydown/autokey (since they're in the background),
  232. etc. If you can get a hold of develop volume 9, it has an article about FBAs. 
  233. It claims that you can only call InitGraf from an FBA, and no other visual
  234. manager (like InitWindows, InitFonts, etc). Otherwise, it's not a faceless
  235. background app.
  236. - --Mel Walker
  237. mwalker@optics.wc.novell.com
  238.  
  239. +++++++++++++++++++++++++++
  240.  
  241. From: ksand@apple.com (Kent Sandvik)
  242. Date: 23 Apr 92 17:41:13 GMT
  243. Organization: MacDTS Mongols
  244.  
  245. In article <1992Apr21.121417.23876@bmers95.bnr.ca>, ross@bnr.ca (Ross Brown)
  246. writes:
  247. > In article <65703@apple.Apple.COM> jackl@Apple.COM (Jack Littleton) writes:
  248. > >You can partially make a program faceless by setting the "canBackground" and
  249. > >"onlyBackground" attributes are set in the SIZE resource.  However, since the
  250. > >by-laws of Faceless Applications state that they can olny receive high level
  251. > >and null events, just setting those attributes won't cut it.  Not only that,
  252. > >but if the program you modify draws windows, menus, etc., it totally blows
  253. > >the concept of "Facelessness".
  254.  
  255. > Please, where are these "by-laws" recorded?  There's not much in IM VI about
  256. > background-only applications.
  257.  
  258. Be patient, C.K. in our group wrote a d e v e l o p article about
  259. background only apps, and it should be published soon. Meanwhile check
  260. his snippets on the Developer CD (or ftp.apple.com).
  261.  
  262. Cheers,
  263. Kent Sandvik
  264. Dynamic Languages will take over the world...
  265.  
  266. ---------------------------
  267.  
  268. From: Pete.Gontier@p811.f70.n109.z1.fidonet.org (Pete Gontier)
  269. Subject: MF scrap && DialogSelect crash
  270. Date: 16 Apr 92 05:15:04 GMT
  271.  
  272. After two years of INIT hacking, I've forgotten a lot of application
  273. boilerplate stuff. Or maybe I'm just getting old.
  274.  
  275. 1. What's the correct incantation to get MultiFinder to recognize it should
  276. propogate your changes to the scrap? After reading a bit, I divined it must
  277. be that you should call SystemEdit to tell MF you're handling one of the
  278. standard menu items. But what to pass? IM says to pass the item in the Edit
  279. menu - 1. But that doesn't work. What does work is item + accMenu. Ideas?
  280.  
  281. 2. What are the most common causes of crashes when calling DialogSelect?
  282.  
  283. 3. Where's some code that scans the event queue for a command-period?
  284.  
  285. +++++++++++++++++++++++++++
  286.  
  287. From: phils@chaos.cs.brandeis.edu (Phil Shapiro)
  288. Date: 21 Apr 92 16:02:01 GMT
  289. Organization: Symantec Corp.
  290.  
  291. In article <703422721.F00003@blkcat.UUCP> Pete.Gontier@p811.f70.n109.z1.fidonet.org (Pete Gontier) writes:
  292.  
  293.  
  294.    1. What's the correct incantation to get MultiFinder to recognize
  295.    it should propogate your changes to the scrap? After reading a bit,
  296.    I divined it must be that you should call SystemEdit to tell MF
  297.    you're handling one of the standard menu items. But what to pass?
  298.  
  299. SystemEdit(copyCmd);  // because PutScrap works like the Edit menu's Copy
  300.  
  301.    3. Where's some code that scans the event queue for a
  302.    command-period?
  303.  
  304. The easiest way to do this (that I've seen) is to hook PostEvent() to
  305. set a global flag if it sees a command-period. This may sound ugly,
  306. but it's cleaner than other techniques I've seen. It removes any
  307. overhead from calling EventAvail() or GetNextEvent(), and it doesn't
  308. have the problems of calling GetOSEvent() or (shudder!) looking at the
  309. event queue directly.
  310.  
  311.     -phil
  312. - --
  313.    Phil Shapiro                                   Software Engineer
  314.    Language Products Group                     Symantec Corporation
  315.            Internet: phils@cs.brandeis.edu
  316.  
  317. +++++++++++++++++++++++++++
  318.  
  319. From: k044477@hobbes.kzoo.edu (Jamie R. McCarthy)
  320. Organization: Kalamazoo College
  321. Date: Tue, 21 Apr 1992 17:20:14 GMT
  322.  
  323. phils@chaos.cs.brandeis.edu (Phil Shapiro) writes:
  324. >Pete.Gontier@p811.f70.n109.z1.fidonet.org (Pete Gontier) writes:
  325. >>
  326. >>3. Where's some code that scans the event queue for a
  327. >>   command-period?
  328. >
  329. >The easiest way to do this (that I've seen) is to hook PostEvent() to
  330. >set a global flag if it sees a command-period. This may sound ugly,
  331.  
  332. Well, no argument here.
  333.  
  334. >but it's cleaner than other techniques I've seen. It removes any
  335. >overhead from calling EventAvail() or GetNextEvent(), and it doesn't
  336. >have the problems of calling GetOSEvent() or (shudder!) looking at the
  337. >event queue directly.
  338.  
  339. Remember, this comes from a guy whose company distributes code that does
  340. exactly that.  :-)  Check out AbortInQueue(), in TBUtilities.c 
  341. (TCL 1.1)--it walks the queue.  I must be missing something--what's so
  342. bad about doing this?
  343. - -- 
  344.  Jamie McCarthy     Internet: k044477@kzoo.edu     AppleLink: j.mccarthy
  345.  I can't contain the furnace where there used to be a guy...
  346.  
  347. +++++++++++++++++++++++++++
  348.  
  349. From: phils@chaos.cs.brandeis.edu (Phil Shapiro)
  350. Date: 21 Apr 92 22:22:46 GMT
  351. Organization: Symantec Corp.
  352.  
  353. In article <1992Apr21.172014.29640@hobbes.kzoo.edu> k044477@hobbes.kzoo.edu (Jamie R. McCarthy) writes:
  354.  
  355.    >but it's cleaner than other techniques I've seen. It removes any
  356.    >overhead from calling EventAvail() or GetNextEvent(), and it doesn't
  357.    >have the problems of calling GetOSEvent() or (shudder!) looking at the
  358.    >event queue directly.
  359.  
  360.    Remember, this comes from a guy whose company distributes code that does
  361.    exactly that.  :-)  Check out AbortInQueue(), in TBUtilities.c 
  362.    (TCL 1.1)--it walks the queue.  I must be missing something--what's so
  363.    bad about doing this?
  364.  
  365. This is bad because it will give you false alarms about
  366. command-periods when your app is in the background. The low memory
  367. queue corresponds to the OS Event queue, which contains all events
  368. before the Process Manager distributes them to applications.
  369.  
  370. This is how THINK C does it as well -- I had to patch GetOSEvent to
  371. prevent it from stealing keydowns to get THINK Back to work properly.
  372.  
  373. Regarding the TCL, I'll see about getting this fixed. As long as you
  374. don't try to call AbortInQueue() when you're in the background, you
  375. should be OK.
  376.  
  377. Does anyone know if code like this is A/UX compatible?
  378.  
  379.     -phil
  380. - --
  381.    Phil Shapiro                                   Software Engineer
  382.    Language Products Group                     Symantec Corporation
  383.            Internet: phils@cs.brandeis.edu
  384.  
  385. +++++++++++++++++++++++++++
  386.  
  387. From: d88-jwa@dront.nada.kth.se (Jon W{tte)
  388. Date: 22 Apr 92 09:31:48 GMT
  389. Organization: Royal Institute of Technology, Stockholm, Sweden
  390.  
  391. .kzoo.edu> k044477@hobbes.kzoo.edu (Jamie R. McCarthy) writes:
  392.  
  393.    >The easiest way to do this (that I've seen) is to hook PostEvent() to
  394.    >set a global flag if it sees a command-period. This may sound ugly,
  395.  
  396.    Well, no argument here.
  397.  
  398.    >but it's cleaner than other techniques I've seen. It removes any
  399.    >overhead from calling EventAvail() or GetNextEvent(), and it doesn't
  400.    >have the problems of calling GetOSEvent() or (shudder!) looking at the
  401.    >event queue directly.
  402.  
  403.    Remember, this comes from a guy whose company distributes code that does
  404.    exactly that.  :-)  Check out AbortInQueue(), in TBUtilities.c 
  405.    (TCL 1.1)--it walks the queue.  I must be missing something--what's so
  406.    bad about doing this?
  407.  
  408. Well, cmd-period is tricky because of international keyboards. You
  409. would almost have to call keytrans yourself...
  410.  
  411. Apart from that, the event queue is in no-no memory under A/UX and is
  412. NOT available to applications except for EventAvail type calls. And
  413. we've all heard that System 8 will look much like A/UX in the memory
  414. protection regard...
  415.  
  416. - -- 
  417. "You should meet yourself someday. I'm sure you would hate it."
  418. - - Me: h+@nada.kth.se; Jon W{tte (The Diplomat - NOT!)
  419.  
  420. +++++++++++++++++++++++++++
  421.  
  422. From: ksand@apple.com (Kent Sandvik)
  423. Date: 24 Apr 92 01:20:21 GMT
  424. Organization: MacDTS Mongols
  425.  
  426. In article <PHILS.92Apr21172246@chaos.cs.brandeis.edu>,
  427. phils@chaos.cs.brandeis.edu (Phil Shapiro) writes:
  428. > In article <1992Apr21.172014.29640@hobbes.kzoo.edu> k044477@hobbes.kzoo.edu
  429. (Jamie R. McCarthy) writes:
  430. >    >but it's cleaner than other techniques I've seen. It removes any
  431. >    >overhead from calling EventAvail() or GetNextEvent(), and it doesn't
  432. >    >have the problems of calling GetOSEvent() or (shudder!) looking at the
  433. >    >event queue directly.
  434. >    Remember, this comes from a guy whose company distributes code that does
  435. >    exactly that.  :-)  Check out AbortInQueue(), in TBUtilities.c 
  436. >    (TCL 1.1)--it walks the queue.  I must be missing something--what's so
  437. >    bad about doing this?
  438. > This is bad because it will give you false alarms about
  439. > command-periods when your app is in the background. The low memory
  440. > queue corresponds to the OS Event queue, which contains all events
  441. > before the Process Manager distributes them to applications.
  442. > This is how THINK C does it as well -- I had to patch GetOSEvent to
  443. > prevent it from stealing keydowns to get THINK Back to work properly.
  444. > Regarding the TCL, I'll see about getting this fixed. As long as you
  445. > don't try to call AbortInQueue() when you're in the background, you
  446. > should be OK.
  447. > Does anyone know if code like this is A/UX compatible?
  448.  
  449. Peeking at the event queue directly won't work under A/UX, it's a nice
  450. little boy that keeps the event queue inside the kernel address space.
  451.  
  452. Tech Note 263 talks about how to intercept command-dot. Here's also
  453. some code (Dave Radcliffe wrote it?) that takes into account the A/UX
  454. case. Sorry it looks very much C++:ish because I recycled the code in
  455. a C++ project:
  456.  
  457.  
  458. //    Pure MacOS routines 
  459. /*
  460.  *    Ascii2KeyCode translates an ASCII character into a virtual keycode.
  461.  *    This is used to locate the '.' key no matter what language or keyboard 
  462.  *    is in use.
  463.  *
  464.  *    This should be called anytime the keyboard script changes (which can
  465.  *    be determined with GetEnvirons (smKeyScript)).
  466.  *
  467.  *    It returns the virtual keycode, or -1 in the event it can't find they key.
  468.  */
  469.  
  470. pascal char TIntDialogBehavior::Ascii2KeyCode (char asciiChar)
  471. {
  472.     char    keyCode;
  473.     Boolean    notDone;
  474.     short    KCHRId;
  475.     Ptr        pKCHR;
  476.     Handle    hKCHR;
  477.     long    state;
  478.     long    ktResult;
  479.     
  480.     hKCHR = nil;
  481.     pKCHR = (Ptr) GetEnvirons (smKCHRCache);    /* Try to get pointer directly */
  482.     
  483.     if (!pKCHR) {                                /* For pre-System 7.0 compatibility */
  484.         KCHRId = (short) GetScript (short(GetEnvirons (smKeyScript)), smScriptKeys);
  485.         hKCHR = GetResource ('KCHR', KCHRId);    /* Get the KCHR resource */
  486.         pKCHR = *hKCHR;                            /* Get the pointer */
  487.     }
  488.  
  489.     notDone = true;
  490.     if (pKCHR) {
  491.         keyCode = 0;
  492.         state = 0;
  493.         
  494.         while ((keyCode <= 0x7F) && notDone) {    /* Loop through all possible keycodes
  495. */
  496.             ktResult = KeyTrans ((pKCHR), keyCode, state);    /* Get the ASCII value */
  497.             if (((ktResult & ktAscii1Mask) == asciiChar) || 
  498.                 ((ktResult & ktAscii2Mask) == asciiChar))     /* Check result for desired char
  499. */
  500.                     notDone = false;
  501.             else
  502.                 keyCode++;                        /* Keep looking */
  503.         }
  504.     }
  505.     
  506.     if (hKCHR)
  507.         ReleaseResource (hKCHR);                /* Clean up */
  508.  
  509.     if (notDone)
  510.         return (-1);
  511.     else
  512.         return (keyCode);
  513. } /* Ascii2KeyCode */
  514.  
  515.  
  516. /*
  517.  *    CheckAUXEventQueue looks in the A/UX event queue for a key event with
  518.  *    the specified keyCode and modifiers.
  519.  *
  520.  *    A/UX does not support the event queue in the Macintosh sense.  Instead,
  521.  *    it maintains a separate data structure in the Unix kernel which is not
  522.  *    directly accessible from a Macintosh application.  To get around this
  523.  *    problem, a special trap called AUXDispatch is provided which allows us
  524.  *    to get the information we need.
  525.  *
  526.  *    CheckAUXEventQueue returns true if it finds the appropriate event.
  527.  *
  528.  *    CheckAUXEventQueue should only be called if A/UX is present.
  529.  */
  530. #define AUX_FIND_EVENT       8
  531. pascal long    AUXDispatch(short selector, char *p)
  532.     = {0xABF9};
  533.  
  534. pascal Boolean TIntDialogBehavior::CheckAUXEventQueue (char keyCode, short
  535. modifiers)
  536. {
  537.     struct {
  538.         EventRecord        mask;
  539.         EventRecord        value;
  540.     } eventFilter;
  541.     
  542.     eventFilter.mask.what = everyEvent;
  543.     eventFilter.value.what = keyDown;            /* Look for a keydown event */
  544.     eventFilter.mask.message = keyCodeMask;
  545.     eventFilter.value.message = keyCode << 8;    /* Set keyCode */
  546.     eventFilter.mask.modifiers = modifiers;
  547.     eventFilter.value.modifiers = modifiers;    /* Set modifiers */
  548.     eventFilter.mask.when = 0;
  549.     eventFilter.mask.where.v = 0;                /* Zero out other stuff */
  550.     eventFilter.mask.where.h = 0;
  551.     return ((AUXDispatch (AUX_FIND_EVENT, (char *) &eventFilter) > 0) && 
  552.         (eventFilter.value.what != nullEvent));    /* Have A/UX look for us */
  553. }    /* CheckAUXEventQueue */
  554.  
  555. /*
  556.  *    UserDidAbort returns true if the user has pressed Command-Period.
  557.  *
  558.  *    It does this by walking the event queue.  Walking the event queue is not
  559.  *    recommended, but since we want a Command-Period event to take priority over
  560.  *    any other events in the queue, looking ahead in the queue is the only way.
  561.  *
  562.  *    Note that for A/UX, this technique does not work as A/UX does not support
  563.  *    the Macintosh event queue structure.  In that case, we call
  564. CheckAUXEventQueue
  565.  *    to find the result.
  566.  */
  567.  
  568. pascal Boolean TIntDialogBehavior::UserDidAbort ()
  569. {
  570.     Boolean        foundEvent;
  571.     char        periodKeyCode;
  572.     EvQElPtr    eventQPtr;
  573.     QHdrPtr        eventQHdr;
  574.     
  575.     /*
  576.      *    It would be best to make periodKeyCode a global and only change it when
  577.      *    the keyboard script changes.  To know when that happens, you could keep
  578.      *    another global, called for example, currentKeyScript, call Ascii2KeyCode
  579.      *    once to initialize periodKeyCode and only call it again if the script
  580.      *    has changed:
  581.      *
  582.      *    if (currentKeyScript != GetEnvirons (smKeyScript))...    // Check to see if
  583. script changed
  584.      */
  585.     periodKeyCode = Ascii2KeyCode ('.');
  586.     if (gConfiguration.hasAUX)        /* If we have A/UX (determined from gConfiguration
  587. */
  588.         foundEvent = CheckAUXEventQueue (periodKeyCode, cmdKey);
  589.     else {
  590.         eventQHdr = GetEvQHdr()    ;                            /* Grab the event queue */
  591.         eventQPtr = (EvQElPtr) eventQHdr->qHead;            /* Grab the first element */
  592.         
  593.         foundEvent = false;                                    /* Assume the event is not there */
  594.         while (eventQPtr && !foundEvent) {
  595.             foundEvent = (((eventQPtr->evtQMessage & keyCodeMask) >> 8) == periodKeyCode
  596. &&
  597.                 (eventQPtr->evtQModifiers & cmdKey));        /* Is this the event we want? */
  598.             if (!foundEvent)
  599.                 eventQPtr = (EvQElPtr) eventQPtr->qLink;    /* If not, grab the next element */
  600.         }
  601.     }
  602.     
  603.     return (foundEvent);        /* Tell them what we found */
  604. } /* UserDidAbort */
  605.  
  606. ---------------------------
  607.  
  608. From: kevin@crash.cts.com (Kevin Hill)
  609. Subject: FileFilter Procedure.  Think C 5.0 StandardGetDialog.
  610. Organization: Crash TimeSharing, El Cajon, CA
  611. Date: Tue, 21 Apr 1992 06:20:37 GMT
  612.  
  613.   I currently am defining a procedure that is:
  614.  
  615. Boolean FileFilterProc(CPBInfo pb,Ptr p) 
  616. {
  617. }
  618.  
  619.  when it gets called, right now it always returns FALSE so that no filtering      
  620. occurs.  However, when it is first called, the mac Bombs at address 0xAxxxxxxx
  621. something.  Also, I noticed when I was looking in the StandardFile.h that 
  622. several of the GetFile routines are being set to certain numbers. Can anyone
  623. give me any hints as to why it crashes, and what the Header is setting when it
  624. declares the functions.
  625.  
  626.   Thanks.
  627.  
  628.  
  629. +++++++++++++++++++++++++++
  630.  
  631. Organization: Penn State University
  632. Date: Tuesday, 21 Apr 1992 08:52:18 EDT
  633. From: Christopher Tate <CXT105@psuvm.psu.edu>
  634.  
  635. In article <1992Apr21.062037.1357@crash.cts.com>, kevin@crash.cts.com (Kevin
  636. Hill) says:
  637. >
  638. >  I currently am defining a procedure that is:
  639. >
  640. >Boolean FileFilterProc(CPBInfo pb,Ptr p)
  641. >{
  642. >}
  643.  
  644. File filter procs have to be declared to use Pascal calling conventions
  645. instead of the usual C conventions.  Change the declaration to
  646.  
  647. pascal Boolean FileFilterProc(CPBInfo pb, Ptr p)
  648. {
  649.    /* do whatever */
  650. }
  651.  
  652. - -------
  653. Christopher Tate        |  "Isn't it funny how the people who cling like
  654.                         |   barnacles to the traditional myths are always
  655. cxt105@psuvm.psu.edu    |   complaining that the rest of us are closed-
  656. Bitnet:  CXT105@PSUVM   |   minded?"                   -- Dr. Dave
  657.  
  658. +++++++++++++++++++++++++++
  659.  
  660. From: ABSURD@applelink.apple.com (Tim Dierks, ToyMeister, Cray abuser)
  661. Date: 23 Apr 92 21:21:15 GMT
  662. Organization: MacDTS, Apple Computer
  663.  
  664. In article <1992Apr21.062037.1357@crash.cts.com>, kevin@crash.cts.com (Kevin Hill) writes:
  665. >   I currently am defining a procedure that is:
  666. > Boolean FileFilterProc(CPBInfo pb,Ptr p) 
  667. > {
  668. > }
  669. >  when it gets called, right now it always returns FALSE so that no filtering      
  670. > occurs.  However, when it is first called, the mac Bombs at address 0xAxxxxxxx
  671. > something.  Also, I noticed when I was looking in the StandardFile.h that 
  672. > several of the GetFile routines are being set to certain numbers. Can anyone
  673. > give me any hints as to why it crashes, and what the Header is setting when it
  674. > declares the functions.
  675.  
  676. Change your declaration to be of type "pascal"; then it will use the
  677. Pascal calling conventions and stop crashing your Mac:
  678.  
  679. pascal Boolean FileFilterProc(CPBInfo pb,Ptr p) 
  680. {
  681. }
  682.  
  683. In your question about the headers, I assume you mean declarations like
  684. the following:
  685.  
  686. pascal void SFGetFile(Point where,
  687.                       ConstStr255Param prompt,
  688.                       FileFilterProcPtr fileFilter,
  689.                       short numTypes,
  690.                       SFTypeList typeList,
  691.                       DlgHookProcPtr dlgHook,
  692.                       SFReply *reply)
  693.     = {0x3F3C,0x0002,0xA9EA}; 
  694.  
  695. In this case, the hex numbers at the end are an inline declaration; the
  696. compiler will insert this assembly code when calling the routine rather
  697. than attempting to JSR to a linked routine (which is what it does when
  698. you call one of your own functions).  In this case, the assembly code
  699. is:
  700.  
  701.     MOVE.W      #$0002,-(A7)
  702.     _Pack3
  703.  
  704. Which pushes the selector for SFGetFile (2) onto the stack, then calls
  705. the trap which all the Standard File routines share (Pack 3).
  706.  
  707. Hope this helps.
  708. Tim Dierks
  709. MacDTS, but I speak for myself
  710.  
  711. ---------------------------
  712.  
  713. From: jlawrie@fraser.sfu.ca (John William Lawrie)
  714. Subject: smooth scrolling
  715. Organization: Simon Fraser University, Burnaby, B.C., Canada
  716. Date: Thu, 23 Apr 1992 10:31:01 GMT
  717.  
  718.  
  719. Does anybody know how to do a smooth scroll?
  720.  
  721.   My problem is this.  I am trying to scroll a region filled with many
  722. different colors.  What happens is that part of the region is out of synch with
  723. the rest.  The bottom half is out of alignment a few pixels.
  724.  
  725.   What I think is happening is that the scroll is happening while the electron
  726. beam is in the middle of the region.  This would cause the top half to be 
  727. updated only when the beam starts the next pass.
  728.  
  729.   My question is this.  Is there any way to synchronize my scroll with the
  730. beam so that I only scroll when the beam is not drawing?
  731.  
  732.   If not, is there another way to acheive a smooth scroll effect?
  733.  
  734. Thanx in advance
  735. John Lawrie
  736.  
  737.  
  738. +++++++++++++++++++++++++++
  739.  
  740. From: k044477@hobbes.kzoo.edu (Jamie R. McCarthy)
  741. Organization: Kalamazoo College
  742. Date: Thu, 23 Apr 1992 15:07:20 GMT
  743.  
  744. jlawrie@fraser.sfu.ca (John William Lawrie) writes:
  745. >
  746. >  My problem is this.  I am trying to scroll a region filled with many
  747. >different colors.  What happens is that part of the region is out of synch with
  748. >the rest.  The bottom half is out of alignment a few pixels.
  749. >
  750. >  What I think is happening is that the scroll is happening while the electron
  751. >beam is in the middle of the region.  This would cause the top half to be 
  752. >updated only when the beam starts the next pass.
  753. >
  754. >  My question is this.  Is there any way to synchronize my scroll with the
  755. >beam so that I only scroll when the beam is not drawing?
  756.  
  757. Yes.  But it takes a little effort.
  758.  
  759. You can tell when the electron beam has begun its trip back to the top
  760. of the screen, because TickCount() will return you a different value.
  761. If you sit in a tight loop:
  762.  
  763. long startTickCount = TickCount();
  764. while (TickCount() != startTickCount) /* do nothing */ ;
  765.  
  766. ...when you get out of the loop, the beam will probably be somewhere
  767. just before starting to paint the top of the screen.  (Its exact
  768. position depends on how long all the vertical-blanking tasks took,
  769. including the one that incremented Ticks.  It may even have already
  770. started its way down the visible screen, but probably not.)
  771.  
  772. Your choices here are two.  If you can update your area in one tick,
  773. then begin immediately.  You'll constantly be rushing ahead of the beam.
  774. If the beam gets ahead of you, your lower area will indeed "fall behind"
  775. just as it is now.
  776.  
  777. If you can update your area in two ticks, wait for a while to let the
  778. beam get a little ahead of you.  Then begin painting.  If you're writing
  779. the whole screen, you have as much time as it takes for the beam to
  780. paint two screens--you start out behind, but it's "running around to
  781. come up behind you again," as Pink Floyd would say.  How _long_ to wait
  782. is not an easy problem, especially given the wide disparity of speeds
  783. that you may be running on.  You can use Gestalt to get your processor
  784. type and/or machine type;  you can do timing loops on TickCount() to see
  785. how many cycles you're doing (though timing the low-memory global Ticks
  786. would be more accurate, you'd lose A/UX and future compatability).  
  787. The faster you estimate the machine to be, the more cycles you should
  788. wait, and nothing but experimenting will help you here.
  789.  
  790. ...and if you can't update your area in two ticks, then you're going to
  791. have tearing no matter what you do, so just kick back, have a cold one,
  792. and start trying to convince people that it's a feature.  :-)
  793. - -- 
  794.  Jamie McCarthy     Internet: k044477@kzoo.edu     AppleLink: j.mccarthy
  795.  My coat contained a furnace where there used to be a guy...
  796.  
  797. +++++++++++++++++++++++++++
  798.  
  799. From: rsfinn@concerto.lcs.mit.edu (Russell S. Finn)
  800. Organization: MIT Laboratory for Computer Science
  801. Date: Thu, 23 Apr 1992 19:19:41 GMT
  802.  
  803. In article <1992Apr23.150720.26827@hobbes.kzoo.edu>, k044477@hobbes.kzoo.edu (Jamie R. McCarthy) writes:
  804. |> You can tell when the electron beam has begun its trip back to the top
  805. |> of the screen, because TickCount() will return you a different value.
  806.  
  807. This is only true on a compact Mac with a built-in monitor.  On
  808. modular Macs, there is still a 60.15 Hz interrupt for compatibility
  809. reasons, and TickCount is still tied to it, but it has nothing to do
  810. with the actual vertical retrace interrupt, which could occur at any
  811. of a number of frequencies depending on the card and monitor used.
  812.  
  813. The solution is to install your own task on the interrupt queue of the
  814. actual card in use; the technique for doing this can be discerned from
  815. a careful reading of the appropriate chapters of Inside Macintosh,
  816. Volume IV.  This task should probably do nothing more than increment a
  817. global variable in the program; then you can use the technique Jamie
  818. described.
  819.  
  820. |> If you sit in a tight loop:
  821. |> 
  822. |> long startTickCount = TickCount();
  823. |> while (TickCount() != startTickCount) /* do nothing */ ;
  824. |> 
  825. |> ...when you get out of the loop, the beam will probably be somewhere
  826. |> just before starting to paint the top of the screen.  (Its exact
  827. |> position depends on how long all the vertical-blanking tasks took,
  828. |> including the one that incremented Ticks.  It may even have already
  829. |> started its way down the visible screen, but probably not.)
  830.  
  831. As it happens, incrementing TickCount is one of the first things that
  832. the standard VBL interrupt handler does, so you can be fairly
  833. confident that the beam hasn't started down the screen yet.
  834.  
  835. - -- Russell S. Finn
  836. rsfinn@lcs.mit.edu
  837.  
  838. +++++++++++++++++++++++++++
  839.  
  840. From: mozart@coos.dartmouth.edu (Sting)
  841. Date: 24 Apr 92 13:01:21 GMT
  842. Organization: Dartmouth College, Hanover, NH
  843.  
  844. In <jlawrie.704025061@sfu.ca> jlawrie@fraser.sfu.ca (John William Lawrie) writes:
  845.  
  846.  
  847. >Does anybody know how to do a smooth scroll?
  848.  
  849. [stuff deleted]
  850.  
  851. >  My question is this.  Is there any way to synchronize my scroll with the
  852. >beam so that I only scroll when the beam is not drawing?
  853.  
  854. >  If not, is there another way to acheive a smooth scroll effect?
  855.  
  856. >Thanx in advance
  857. >John Lawrie
  858.  
  859. There is a Vertical Blanking manager in the 128K (and higher) ROMs that main-
  860. tains a queue of things to do in the interval between when the beam shuts off
  861. at the bottom right corner of the screen and flicks back to the top to start
  862. its next pass.  I don't have IM right here in front of me, but I believe you
  863. could at the very least use this manager to help synchronize with the retrace
  864. cycle.
  865.  
  866. - -Mike
  867.  
  868. - --
  869. Michael J. Fromberger            | Take a look at my new toy,
  870. Composer, Guitarist            | It'll blow your head in two, oh boy!
  871. Sting@Dartmouth.EDU                | Truth hits everybody
  872.   friendly email welcome!!         | Truth hits everyone...  (The Police)
  873.  
  874. ---------------------------
  875.  
  876. From: ccs011@fred.ucdavis.edu (James Davis)
  877. Subject: Are you a developer? Ive got a question.
  878. Date: 24 Apr 92 03:04:51 GMT
  879. Organization: Computing Services, UC Davis
  880.  
  881. If you're an apple developer (associate or partner) and
  882. dont mind a few questions, could you drop me a note?  I had
  883. a few questions about the developer mailing, but since half
  884. that stuff is marked confidential dont want to ask in a public 
  885. forum.
  886.  
  887. Thanks for the willingness to help,
  888. James Davis (jedavis@ucdavis.edu) : University California : Computing Services
  889.  
  890. +++++++++++++++++++++++++++
  891.  
  892. From: mspace@netcom.com (Brian Hall)
  893. Date: Fri, 24 Apr 92 04:25:45 GMT
  894. Organization: Netcom - Online Communication Services  (408 241-9760 guest) 
  895.  
  896. In article <12555@ucdavis.ucdavis.edu> ccs011@fred.ucdavis.edu (James Davis) writes:
  897. >If you're an apple developer (associate or partner) and
  898. >dont mind a few questions, could you drop me a note?  I had
  899. >a few questions about the developer mailing, but since half
  900. >that stuff is marked confidential dont want to ask in a public 
  901. >forum.
  902. >
  903. >Thanks for the willingness to help,
  904. >James Davis (jedavis@ucdavis.edu) : University California : Computing Services
  905.  
  906. Call the Apple Developer Group at 408/996-1010.  They will be happy to send
  907. you a package explaining the various developer programs, what you need to
  908. do to qualify, and what you get in return.
  909.  
  910. - -- 
  911. +-----------------------------------------------------------------------------+
  912. | Brian Hall, Mark/Space Softworks                                            |
  913. | mspace@netcom.com; Applelink, America Online: MarkSpace                     |
  914. +-----------------------------------------------------------------------------+
  915.  
  916. ---------------------------
  917.  
  918. End of C.S.M.P. Digest
  919. **********************
  920.